﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using YArchitech.Controls;

namespace YArchitech.HVAC.AuxiliaryCurve
{
	public abstract class AuxiliaryCurve
	{
		public AuxiliaryCurve(double xSideArgu, double ySideArgu, ExternalCommandData amdArgu, AuxiliaryCurveType typeArgu)
		{
			this.xSide = xSideArgu;
			this.ySide = ySideArgu;
			this.type = typeArgu;
			this.Ids = new List<ElementId>();
			this.dicX = new Dictionary<XYZ, XYZ>();
			this.dicY = new Dictionary<XYZ, XYZ>();
			this.factory = new AuxiliaryDrawFactory(amdArgu, this.dicX, this.dicY, ref this.Ids, typeArgu, null);
			this.objectDraw = this.factory.CreateAuxiliaryDraw();
			this.curveIdsSave = new AuxiliaryCurveIdsSave(this.Ids);
		}

		public bool Draw()
		{
			if (this.objectPointsGet == null)
			{
				return false;
			}
			this.objectPointsGet.GetPoints();
			try
			{
				if (this.objectDraw is ModelLineDraw && this.objectPointsGet is PlaneGetPoint)
				{
					((ModelLineDraw)this.objectDraw).CurPlane = ((PlaneGetPoint)this.objectPointsGet).FacePlane;
				}
			}
			catch (NullReferenceException)
			{
				YJKMessageBox.Information("该对象不包括平面,无法绘制!");
				return false;
			}
			this.objectDraw.DrawCurve();
			this.curveIdsSave.SaveElementIds();
			return true;
		}

		protected double xSide;

		protected double ySide;

		protected AuxiliaryCurveType type;

		protected AuxiliaryDraw objectDraw;

		protected AuxiliaryPointsGet objectPointsGet;

		protected AuxiliaryHandldSelPoints objectHandle;

		protected ICollection<ElementId> Ids;

		protected Dictionary<XYZ, XYZ> dicX;

		protected Dictionary<XYZ, XYZ> dicY;

		protected AuxiliaryDrawFactory factory;

		protected AuxiliaryCurveIdsSave curveIdsSave;
	}
}
